//
//  DetailViewController.m
//  Aksharalu
//
//  Created by surya gaddipati on 5/23/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "DetailViewController.h"


@implementation DetailViewController
@synthesize image, text;


-(void) playSound{

	// Get the main bundle for the app
	CFBundleRef mainBundle;
	mainBundle = CFBundleGetMainBundle ();
	
	CFURLRef		soundFileURLRef;
	SystemSoundID	soundFileObject;
	// Get the URL to the sound file to play
	soundFileURLRef  =	CFBundleCopyResourceURL (
												 mainBundle,
												 CFSTR ("1"),
												 CFSTR ("aiff"),
												 NULL
												 );
	
	// Create a system sound object representing the sound file
	AudioServicesCreateSystemSoundID (
									  soundFileURLRef,
									  &soundFileObject
									  );
	AudioServicesPlaySystemSound  (soundFileObject);	
	//AudioServicesDisposeSystemSoundID (soundFileObject);
	CFRelease (soundFileURLRef);
	
}

-(void) selectDetail : (NSInteger) detailId{
		///self.selectedDetailId = detailId;
	[self playSound];
	NSString  *filename = [NSString stringWithFormat:@"d%d1.gif", detailId];
	image.image = [UIImage imageNamed:filename];
	NSMutableArray * standbyAnimationImages = [[NSMutableArray alloc] init];

	for (NSUInteger i=2; i<=12; i++) {
		filename = [NSString stringWithFormat:@"d%d%d.gif",detailId, i];
		[standbyAnimationImages addObject:[UIImage imageNamed:filename]];
	}
	
	image.animationImages = standbyAnimationImages;
	image.animationDuration = 2;
	image.animationRepeatCount = 0;
	[image startAnimating];
	
	
	//[text setText:@"text"];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}


@end
